function getRandomInt(min, max) {
  return Math.floor(Math.random() * (max - min + 1) +min)
}

export function shuffle(arr) {
  let new_arr = []
  arr.forEach((item) => {
    new_arr.push(item)
  })
  for(let i = 0; i < new_arr.length; i++) {
    let j = getRandomInt(0, i)
    let t = new_arr[i]
    new_arr[i] = new_arr[j]
    new_arr[j] = t
  }
  return new_arr
}

export function debounce(func, delay) {
  let timer

  return function (...args) {
    if(timer) {
      clearTimeout(timer)
    }
    timer = setTimeout(() => {
      func.apply(this, args)
    }, delay)
  }
}